﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

using BlueCMS.Core.Pages;

namespace BlueCMS.Core
{
    public class CmsSession
    {
        const string RENDER_MODE_KEY = "BlueCMS.Core.CmsSession.RENDER_MODE_KEY";

        public static RenderMode RenderMode
        {
            get 
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies[RENDER_MODE_KEY];
                if (cookie == null)
                    return RenderMode.Display;
                if(!Enum.IsDefined(typeof(RenderMode), cookie.Value))
                    return RenderMode.Display;

                return (RenderMode)Enum.Parse(typeof(RenderMode), cookie.Value);
            }

            set
            {
                HttpContext.Current.Response.Cookies[RENDER_MODE_KEY].Value = value.ToString();
            }
        }
    }
}
